# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=rsync
pkgver=3.1.3
pkgrel=1
pkgdesc="A file transfer program to keep remote files in sync"
arch=('i686' 'x86_64')
url="https://rsync.samba.org"
groups=('net-utils')
license=('GPL3')
depends=('perl')
source=("https://download.samba.org/pub/rsync/$pkgname-$pkgver.tar.gz"
        rsync-3.1.0-msys2.patch
        ssh-6-option.patch)
sha256sums=('55cc554efec5fdaad70de921cd5a5eeb6c29a95524c715f3bbf849235b0800c0'
            '4fee5ba148b2fb4cd910f75e0271f5d66854954cbfaa34a6d9b814de9af2fb05'
            'ea88046d8935e7a597cca7379d21edffefa520792d896bd7ce663b4cdc0f2069')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -i ${srcdir}/rsync-3.1.0-msys2.patch
  patch -p1 -i ${srcdir}/ssh-6-option.patch

  autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
      --build=${CHOST} \
      --prefix=/usr
  
  make reconfigure
  make man all
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make test
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -Dm755 support/rrsync "${pkgdir}/usr/lib/rsync/rrsync"
}
